// import { Component } from '@angular/core';
// import { IonicPage, NavController, NavParams } from 'ionic-angular';


import { Component, ViewChild, ElementRef } from '@angular/core';

import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { ProjectService } from "./services/project.service";



declare var BMap;

// declare var BMAP_STATUS_SUCCESS;

/**
 * Generated class for the ProjectPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-project',
  templateUrl: 'project.html',
})
export class ProjectPage {

  // @ViewChild('map') map_container: ElementRef;
  @ViewChild('map2') map_container: ElementRef;
  map: any;//地图对象
  marker: any;//标记
  geolocation1: any;
  myIcon: any;
  data: any;

  name: any;
  area:any;
  capacity: any;
  functions: any;
  description: any;
  remarks: any;


  constructor(
    public service: ProjectService,
    public navCtrl: NavController, public navParams: NavParams) {
    this.myIcon = new BMap.Icon("assets/icon/favicon.ico", new BMap.Size(30, 30));
  }

  ionViewDidLoad() {

    let map = this.map = new BMap.Map(this.map_container.nativeElement, { enableMapClick: true });//创建地图实例

    // map.centerAndZoom("广州",17); //设置城市设置中心和地图显示级别
    let point = new BMap.Point(120.753244, 31.311889);//坐标可以通过百度地图坐标拾取器获取
    map.centerAndZoom(point, 17);//设置中心和地图显示级别

    map.addControl(new BMap.MapTypeControl());
    // map.setCurrentCity("广州"); 

    // let sizeMap = new BMap.Size(10, 80); //显示位置
    map.addControl(new BMap.NavigationControl());

    var new_point = new BMap.Point(120.753244, 31.311889);
    var marker1 = new BMap.Marker(new_point);                              // 创建标注  
    map.addOverlay(marker1);


    map.enableScrollWheelZoom(true); //启动滚轮放大缩小，默认禁用
    map.enableContinuousZoom(true); //连续缩放效果，默认禁用

    // let myIcon = new BMap.Icon("assets/icon/favicon.ico", new BMap.Size(300, 157));

    // let marker = this.marker = new BMap.Marker(point, { icon: myIcon });   
    // map.addOverlay(marker);

    //项目信息显示
    this.service.product()
      .subscribe(data => {
        this.data = data;


        this.name = data.name;
        this.area = data.area;
        this.capacity = data.capacity;
        this.functions = data.functions;
        this.description = data.description;
        this.remarks = data.remarks;

      }, err => console.log(err));


  }



}
